package com.intermancer.predictor.evaluator;

import java.io.PrintWriter;

import com.intermancer.predictor.data.ConsumeResponse;
import com.intermancer.predictor.data.Quantum;

public class EvaluatorWriterWrapper implements Evaluator {
	
	private Evaluator wrappedInstance;
	private PrintWriter outputWriter;
	
	public EvaluatorWriterWrapper() {
		
	}
	
	public EvaluatorWriterWrapper(Evaluator wrappedInstance, PrintWriter outputWriter) {
		this.wrappedInstance = wrappedInstance;
		this.outputWriter = outputWriter;
	}

	@Override
	public double getScore() {
		return wrappedInstance.getScore();
	}

	@Override
	public void init() {
		wrappedInstance.init();
	}

	@Override
	public boolean handle(ConsumeResponse consumeResponse,
			Quantum quantum) {
		boolean returnValue = wrappedInstance.handle(consumeResponse, quantum);
		outputWriter.println("    Evaluator score: " + wrappedInstance.getScore());
		return returnValue;
	}

	public Evaluator getWrappedInstance() {
		return wrappedInstance;
	}

	public void setWrappedInstance(AbstractChannelEvaluator wrappedInstance) {
		this.wrappedInstance = wrappedInstance;
	}

	public PrintWriter getOutputWriter() {
		return outputWriter;
	}

	public void setOutputWriter(PrintWriter outputWriter) {
		this.outputWriter = outputWriter;
	}

}